<?php

declare(strict_types=1);

namespace Zms\AdminElementPlus\FormCreate\FormItem;

/**
 * 开关
 * Class Color
 */
class DataTime extends FormItemAbstract
{
    protected string $_type = 'DatePicker';

    /**
     * 获取值类型
     * @return string
     */
    public function valueType(): string
    {
        return self::VALUE_TYPE_STRING;
    }


    public function defaultProps(): array
    {
        return [
            'type' => "datetime",
            'placeholder' => "请选择日期",
        ];
    }

    /**
     * Radio constructor.
     * @param string $field
     * @param string $title
     * @param string $value
     */
    public function __construct(string $field, string $title, string $value = '')
    {
        $this->_title = $title;
        $this->_field = $field;
        $this->_value = $value;
        $this->clearable(false);
    }


    /**
     * 防止点击可选清空
     * @param bool $clearable
     * @return FormItemAbstract
     */
    public function clearable(bool $clearable): FormItemAbstract
    {
        if (isset($this->_props['clearable'])) {
            unset($this->_props['clearable']);
        }
        return $this;
    }


    /**
     * 时间类型
     * @param string $type
     * @return FormItemAbstract
     */
    public function type(string $type): FormItemAbstract
    {
        return $this->props('type', $type);
    }
}